using System.Collections.Generic;
using System.Linq;

namespace VI.Fsc.OperatorGui.Models.Fsc.Configuration
{
    public class StructureTree
    {
        private readonly Dictionary<string, CStructureItem> structureTree;

        public StructureTree(Dictionary<string, CStructureItem> structureTree)
        {
            this.structureTree = structureTree;
        }

        public IEnumerable<string> GetAvailableCommandsOfComponent(string component)
        {
            string commandsPath = component + "/Commands";
            return structureTree
                .Keys
                .Where(x => x.StartsWith(commandsPath))
                .Where(x => x.Replace(commandsPath, string.Empty).Length > 0)
                .Select(x => x.Replace(commandsPath + "/", string.Empty));
        }
    }
}